package com.example.helloworld.tools;

import java.util.Comparator;

import com.example.helloworld.ItemObject;


public class Tools {
	public static void print(String text){
		System.out.println("MYPRINT: " + text);
	}
	
	public static class SectionSort{
		
		public static final int ASC = 1;
		public static final int DESC = 2;
		
	}
	
	public static class ItemObjectSort{
		public static final int SORT_NONE = 0;
		public static final int TITLE = 1;
		public static final int STATUS = 2;
		public static final int PRICE = 3;
	}
	
	
	public static class Comparators{
		public static class ComparatorTitle implements Comparator<ItemObject>{

			@Override
			public int compare(ItemObject first, ItemObject second) {
				// TODO Auto-generated method stub
				return first.getTitle().compareTo(second.getTitle());
			}
			
		}
		
		public static class ComparatorPrice implements Comparator<ItemObject>{

			@Override
			public int compare(ItemObject first, ItemObject second) {
				// TODO Auto-generated method stub
				int result = 0;
				int firstPrice = first.getPrice();
				int secondPrice = second.getPrice();
				if(firstPrice < secondPrice) {
					result = -1;
				} else if(firstPrice > secondPrice) {
					result = 1;
				}
				return result; 
			}
			
		}
		
		public static class ComparatorStatus implements Comparator<ItemObject>{

			@Override
			public int compare(ItemObject first, ItemObject second) {
				// TODO Auto-generated method stub
				return first.getStatus().compareTo(second.getStatus());
			}
			
		}
	}
	
	public static class DBTableItems{

		public static final String TABLE = "items";
		// fields
		public static final String ID = "id";
		public static final String TITLE = "title";
		public static final String STATUS = "status";
		public static final String SECTION = "section_id";
		public static final String PRICE = "price";
		
		public static final String[] ALL_FIELDS = {TITLE, STATUS, PRICE, SECTION, ID};
	}
	
	public static class DBTableSections{

		public static final String TABLE = "section";
		// fields
		public static final String ID = "id";
		public static final String TITLE = "title";
		
		public static final String[] ALL_FIELDS = {TITLE, ID};
	}		
}
